package com.example.service1.common.api.fallback;

import com.example.service1.common.api.Service1;
import com.example.service1.common.api.entity.ResponseResult;
import com.example.service1.common.api.entity.ServiceStateCode;
import com.example.service1.common.dto.FileTestDto;
import com.example.service1.common.dto.TestDto;
import com.example.service1.common.vo.TestVo;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
public class Service1Fallback implements Service1 {

    @Override
    public ResponseResult<TestVo> noArgGet() {
        System.out.println("当feign的fallback与服务熔断都设置时");
        return ResponseResult.failure(ServiceStateCode.CURRENT_LIMITING);
    }

    @Override
    public ResponseResult<TestVo> pathArgGet(String name, LocalDate date) {
        System.out.println("pathArgGet  服务降级");
        return ResponseResult.failure(ServiceStateCode.CURRENT_LIMITING);
    }

    @Override
    public ResponseResult<TestVo> pathAndBodyArgPost(String name, LocalDate date, TestDto dto) {
        System.out.println("pathAndBodyArgPost  服务降级");
        return ResponseResult.failure(ServiceStateCode.CURRENT_LIMITING);
    }

    @Override
    public ResponseResult<TestVo> pathAndBodyArgPut(String name, LocalDate date, TestDto dto) {
        System.out.println("pathAndBodyArgPut  服务降级");
        return ResponseResult.failure(ServiceStateCode.CURRENT_LIMITING);
    }

    @Override
    public ResponseResult<TestVo> pathAndBodyArgAndFileArgPost(String e, FileTestDto fileTestDto) {
        System.out.println("pathAndBodyArgAndFileArgPost  服务降级且不支持文件上传，是报错引起的");
        return ResponseResult.failure(ServiceStateCode.CURRENT_LIMITING);
    }
}
